package com.lly.bigdata.bgayx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lly.bigdata.bgayx.entity.SysRoleMenu;
import com.lly.bigdata.bgayx.mapper.SysRoleMenuMapper;
import com.lly.bigdata.bgayx.service.ISysRoleMenuService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 角色与菜单对应关系 服务实现类
 * </p>
 *
 * @author lly
 * @since 2020-10-21
 */
@Service
public class SysRoleMenuServiceImpl extends ServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements ISysRoleMenuService {

    /**
     * 查询角色和菜单
     *
     * @param roleid
     * @return
     */
    @Override
    public List<String> queryMenuRole(String roleid) {
        QueryWrapper<SysRoleMenu> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("role_id", roleid);
        List<SysRoleMenu> list = this.baseMapper.selectList(queryWrapper);
        List<String> menus = list.stream().map(v -> v.getMenuId()).collect(Collectors.toList());
        return menus;
    }
}
